#include<iostream>
#include<cmath>
using namespace std;


int main()
{
	long long p1, q1, r1;
	cin >> p1 >> q1 >> r1;
	for (long long i = 3; i <= 16; i++)
	{
		long long pi = 0, qi = 0, ri = 0;
		long long p = p1, q = q1, r = r1;
		for (long long j = 0; p != 0 || q != 0 || r != 0; j++)
		{
			long long tmp1 = p % 10;
			pi += tmp1 * pow(i, j);
			p /= 10;
			long long tmp2 = q % 10;
			qi += tmp2 * pow(i, j);
			q /= 10;
			long long tmp3 = r % 10;
			ri += tmp3 * pow(i, j);
			r /= 10;
		}
        if (qi * pi == ri)
		{
			cout << i << endl;
				return 0;
		}
		
	}
	cout << 0 << endl;
	return 0;
}
